using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Network;
using MicroMsg.Scene;
using System;
using System.Collections.Generic;
namespace MicroMsg.Manager
{
	public class StatReportMgr
	{
		private const string TAG = "StatReportMgr";
		private const int MAX_REPORT_LOG_SIZE = 29696;
		private const int BLOCK_REPORT_LOG_SIZE = 6144;
		private EventWatcher mWatcher;
		private List<KVStat> mListKVStats = new List<KVStat>();
		private EventWatcher mWatcherWriteOplog;
		public StatReportMgr()
		{
			this.mWatcher = new EventWatcher(this, null, new EventHandlerDelegate(this.onSysMsgStatReport));
			EventCenter.registerEventWatcher(EventConst.SYS_MSG_STAT_REPORT, this.mWatcher);
			this.mWatcherWriteOplog = new EventWatcher(this, null, new EventHandlerDelegate(this.onWriteOplog));
			EventCenter.registerEventWatcher(EventConst.ON_ACCOUNT_LOGOUT, this.mWatcherWriteOplog);
			EventCenter.registerEventWatcher(EventConst.ON_PROGRAM_EXIST, this.mWatcherWriteOplog);
		}
		public void addStatItem(enKVStatKey enKVStatKey_0, string value)
		{
			KVStat kVStat = new KVStat();
			kVStat.enKVStatKey_0 = enKVStatKey_0;
			kVStat.value = value;
			this.mListKVStats.Add(kVStat);
		}
		private void onWriteOplog(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			if (this.mListKVStats.get_Count() <= 0)
			{
				return;
			}
			if (evtArgs.mEventID != EventConst.ON_ACCOUNT_LOGOUT && !AccountMgr.isLogin)
			{
				return;
			}
			OpLogMgr.OplogAddKVStat(this.mListKVStats);
			this.mListKVStats.Clear();
		}
		private void onSysMsgStatReport(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			string text = evtArgs.mObject as string;
			if (text == null)
			{
				Log.smethod_1("StatReportMgr", "on received sysmsg to stat report without fromuser.");
				return;
			}
			if (!text.Equals("weixin"))
			{
				Log.smethod_1("StatReportMgr", "on received sysmsg to stat report from=" + text);
				return;
			}
			Log.smethod_5("StatReportMgr", "on received sysmsg to stat report...");
			PushChannelSettings pushChannelSettings = GConfigMgr.smethod_0<PushChannelSettings>();
			Log.smethod_5("APP", "reg push uri =" + pushChannelSettings.strRegChannelUri);
			Log.smethod_5("APP", "local push uri =" + pushChannelSettings.strPushChannelUri);
			PushNotifySwitch @int = (PushNotifySwitch)ConfigMgr.getInt("nSwitchPushNotify", 0);
			Log.smethod_5("APP", "push switch =" + @int);
			FlowControl.printInfo();
			HostService.printInfo();
			Connector.printInfo();
			AppInfoHelper.printfInfo();
			string logString = Log.getLogString(29696);
			int num = (logString.get_Length() + 6143) / 6144;
			for (int i = 0; i < num; i++)
			{
				int num2;
				if (i == num - 1)
				{
					num2 = logString.get_Length() - i * 6144;
				}
				else
				{
					num2 = 6144;
				}
				string value = logString.Substring(i * 6144, num2);
				OpLogMgr.OplogAddKVStat(4, value);
			}
			ServiceCenter.sceneNewSync.doScene(7, syncScene.MM_NEWSYNC_SCENE_OTHER);
		}
	}
}
